<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 创建一个定时器，2s后执行
    var timeId = setTimeout(function(){
        document.write('<h1>hello</h1>');
    },2000);
    // 取消定时器
    clearTimeout(timeId);

    var Interval = setInterval(function(){
        var date = new Date();
        document.writeln(date.getSeconds());
    },2000);
    clearInterval(Interval);
</script>
</html>